<template>
  <div>
<van-form @submit="onSubmit">
  <van-field
    v-model="username"
    name="用户名"
    label="用户名"
    placeholder="用户名"
    :rules="[{ required: true, message: '请填写用户名' }]"
  />
  <van-field
    v-model="password"
    type="password"
    name="密码"
    label="密码"
    placeholder="密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit">提交</van-button>
  </div>
</van-form>
<!-- <button ></button> -->
<!-- <van-button type="primary" @click="ajaxSta()">主要按钮</van-button> -->
  </div>
</template>

<script>
import axios from 'axios';
export default {
  data() {
    return {
      username: '',
      password: '',
    };
  },
  mounted() {
    
  },
  methods: {
    ajaxSta(){
      let url = `http://121.41.51.182:3000/daily_signin`;
            return axios({
                method: "get",
                timeout: 1000 * 30,
                url: url,
                dataType: "json",
                withCredentials: true
            })
                .then((res) => {
                    console.log(res);
                    this.$toast.success('登陆成功');
                    return res;
                })
                .catch(function (error) {
                    alert("获取失败，请稍后重试");
                    console.log(error);
                });
    },
    onSubmit(values) {
      console.log('submit', values);
            let url = `http://121.41.51.182:3000/login/cellphone?phone=${values.用户名}&password=${values.密码}`;
            return axios({
                method: "get",
                timeout: 1000 * 30,
                url: url,
                dataType: "json",
            })
                .then((res) => {
                    console.log(res);
                    
                    this.$toast.success('登陆成功');
                    return res;
                })
                .catch(function (error) {
                    alert("获取失败，请稍后重试");
                    console.log(error);
                });
    },
  },

};
</script>

<style scoped>
/* input{
  border: 1px solid red;
} */
</style>